﻿// -----------------------------------------------------------------------
// <copyright file="Log.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------
namespace WpfDevelopment.MVVM
{
    using System.Collections.Generic;
    using System.Threading;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class Log : ILog
    {
        private Queue<LogItem> logQueue = new Queue<LogItem>();

        /// <summary>
        /// The single instance method that writes to the log file
        /// </summary>
        /// <param name="message">The message to write to the log</param>
        public void Write(string message)
        {
            // Lock the queue while writing to prevent contention for the log file
            lock (this.logQueue)
            {
                this.logQueue.Enqueue(new LogItem(message));
            }
        }
    }
}
